﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Base.Master" AutoEventWireup="true"
    CodeBehind="ManageInstances.aspx.cs" Inherits="masterview.WebForm5" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table width="100%">
        <tr valign="top">
            <td style="width: 50%">
                <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" CellPadding="4"
                    DataKeyNames="SII_ID" DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None"
                    AllowPaging="True" AllowSorting="True" Width="100%">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField Visible="False" DataField="SII_ID" HeaderText="SII_ID" InsertVisible="False"
                            ReadOnly="True" SortExpression="SII_ID" />
                        <asp:TemplateField HeaderText="Instance Name" SortExpression="SII_NAME">
                            <ItemTemplate>
                                <b><a href="<%#Eval("SII_URL")%>">
                                    <%#Eval("SII_NAME")%></a> (<%#((bool)Eval("SII_IS_ACTIVE")) ? "<span style='color: green'>Active</span>" : "<span style='color: red'>Not Active</span>"%>)</b>
                                <br />
                                <span style="font-size: smaller;">Owner: <span style="color: Gray;">
                                    <%#Eval("SII_OWNER_NAME")%>
                                    (email: <a href="mailto:<%#Eval("SII_OWNER_EMAIL")%>">
                                        <%#Eval("SII_OWNER_EMAIL")%></a>)
                                    <br />
                                    <%#Eval("SII_DESCRIPTION")%>
                                </span></span>
                            </ItemTemplate>
                            <ControlStyle Width="95%" />
                        </asp:TemplateField>
                    </Columns>
                    <EditRowStyle BackColor="#999999" />
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                    <SortedAscendingCellStyle BackColor="#E9E7E2" />
                    <SortedAscendingHeaderStyle BackColor="#506C8C" />
                    <SortedDescendingCellStyle BackColor="#FFFDF8" />
                    <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                </asp:GridView>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:LocalDataBase %>"
                    SelectCommand="SELECT * FROM [SERVICE_INSTANCE_INFORMATION]"></asp:SqlDataSource>
            </td>
            <td style="width: 50%">
                <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="100%" AutoGenerateRows="False"
                    CellPadding="4" DataKeyNames="SII_ID" DataSourceID="SqlDataSource2" Visible="true"
                    ForeColor="#333333" GridLines="None" OnItemUpdated="DetailsView1_ItemUpdated">
                    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                    <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                    <EditRowStyle Width="85%" BackColor="#999999" />
                    <FieldHeaderStyle Width="15%" BackColor="#E9ECF1" Font-Bold="True" />
                    <Fields>
                        <asp:BoundField DataField="SII_ID" HeaderText="Instance Id" InsertVisible="False"
                            ReadOnly="True" SortExpression="SII_ID" />
                        <asp:BoundField DataField="INSTALL_ID" HeaderText="Service Id" SortExpression="INSTALL_ID">
                            <ControlStyle Width="20px" />
                        </asp:BoundField>
                        <asp:CheckBoxField DataField="SII_IS_ACTIVE" HeaderText="Is Active" SortExpression="SII_IS_ACTIVE" />
                        <asp:BoundField DataField="SII_NAME" HeaderText="Instance Name" SortExpression="SII_NAME">
                            <ControlStyle Width="99%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SII_DESCRIPTION" HeaderText="Description" SortExpression="SII_DESCRIPTION">
                            <ControlStyle Width="99%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SII_OWNER_NAME" HeaderText="Owner Name" SortExpression="SII_OWNER_NAME">
                            <ControlStyle Width="99%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SII_OWNER_EMAIL" HeaderText="Owner email" SortExpression="SII_OWNER_EMAIL">
                            <ControlStyle Width="99%" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SII_URL" HeaderText="URL" SortExpression="SII_URL">
                            <ControlStyle Width="99%" />
                        </asp:BoundField>
                        <asp:CommandField ShowEditButton="True" ShowDeleteButton="True" ShowInsertButton="True" />
                    </Fields>
                    <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                    <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                </asp:DetailsView>
                <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:LocalDataBase %>"
                    SelectCommand="SELECT * FROM [SERVICE_INSTANCE_INFORMATION] WHERE ([SII_ID] = @SII_ID) ORDER BY [INSTALL_ID]"
                    ConflictDetection="CompareAllValues" DeleteCommand="DELETE FROM [SERVICE_INSTANCE_INFORMATION] WHERE [SII_ID] = @original_SII_ID AND [INSTALL_ID] = @original_INSTALL_ID AND [SII_IS_ACTIVE] = @original_SII_IS_ACTIVE AND (([SII_NAME] = @original_SII_NAME) OR ([SII_NAME] IS NULL AND @original_SII_NAME IS NULL)) AND (([SII_DESCRIPTION] = @original_SII_DESCRIPTION) OR ([SII_DESCRIPTION] IS NULL AND @original_SII_DESCRIPTION IS NULL)) AND (([SII_OWNER_NAME] = @original_SII_OWNER_NAME) OR ([SII_OWNER_NAME] IS NULL AND @original_SII_OWNER_NAME IS NULL)) AND (([SII_OWNER_EMAIL] = @original_SII_OWNER_EMAIL) OR ([SII_OWNER_EMAIL] IS NULL AND @original_SII_OWNER_EMAIL IS NULL)) AND [SII_URL] = @original_SII_URL"
                    InsertCommand="INSERT INTO [SERVICE_INSTANCE_INFORMATION] ([INSTALL_ID], [SII_IS_ACTIVE], [SII_NAME], [SII_DESCRIPTION], [SII_OWNER_NAME], [SII_OWNER_EMAIL], [SII_URL]) VALUES (@INSTALL_ID, @SII_IS_ACTIVE, @SII_NAME, @SII_DESCRIPTION, @SII_OWNER_NAME, @SII_OWNER_EMAIL, @SII_URL)"
                    OldValuesParameterFormatString="original_{0}" UpdateCommand="UPDATE [SERVICE_INSTANCE_INFORMATION] SET [INSTALL_ID] = @INSTALL_ID, [SII_IS_ACTIVE] = @SII_IS_ACTIVE, [SII_NAME] = @SII_NAME, [SII_DESCRIPTION] = @SII_DESCRIPTION, [SII_OWNER_NAME] = @SII_OWNER_NAME, [SII_OWNER_EMAIL] = @SII_OWNER_EMAIL, [SII_URL] = @SII_URL WHERE [SII_ID] = @original_SII_ID AND [INSTALL_ID] = @original_INSTALL_ID AND [SII_IS_ACTIVE] = @original_SII_IS_ACTIVE AND (([SII_NAME] = @original_SII_NAME) OR ([SII_NAME] IS NULL AND @original_SII_NAME IS NULL)) AND (([SII_DESCRIPTION] = @original_SII_DESCRIPTION) OR ([SII_DESCRIPTION] IS NULL AND @original_SII_DESCRIPTION IS NULL)) AND (([SII_OWNER_NAME] = @original_SII_OWNER_NAME) OR ([SII_OWNER_NAME] IS NULL AND @original_SII_OWNER_NAME IS NULL)) AND (([SII_OWNER_EMAIL] = @original_SII_OWNER_EMAIL) OR ([SII_OWNER_EMAIL] IS NULL AND @original_SII_OWNER_EMAIL IS NULL)) AND [SII_URL] = @original_SII_URL">
                    <DeleteParameters>
                        <asp:Parameter Name="original_SII_ID" Type="Int64" />
                        <asp:Parameter Name="original_INSTALL_ID" Type="Int64" />
                        <asp:Parameter Name="original_SII_IS_ACTIVE" Type="Boolean" />
                        <asp:Parameter Name="original_SII_NAME" Type="String" />
                        <asp:Parameter Name="original_SII_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="original_SII_OWNER_NAME" Type="String" />
                        <asp:Parameter Name="original_SII_OWNER_EMAIL" Type="String" />
                        <asp:Parameter Name="original_SII_URL" Type="String" />
                    </DeleteParameters>
                    <InsertParameters>
                        <asp:Parameter Name="INSTALL_ID" Type="Int64" />
                        <asp:Parameter Name="SII_IS_ACTIVE" Type="Boolean" />
                        <asp:Parameter Name="SII_NAME" Type="String" />
                        <asp:Parameter Name="SII_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="SII_OWNER_NAME" Type="String" />
                        <asp:Parameter Name="SII_OWNER_EMAIL" Type="String" />
                        <asp:Parameter Name="SII_URL" Type="String" />
                    </InsertParameters>
                    <SelectParameters>
                        <asp:ControlParameter ControlID="GridView1" Name="SII_ID" DefaultValue="0" PropertyName="SelectedValue"
                            Type="Int64" />
                    </SelectParameters>
                    <UpdateParameters>
                        <asp:Parameter Name="INSTALL_ID" Type="Int64" />
                        <asp:Parameter Name="SII_IS_ACTIVE" Type="Boolean" />
                        <asp:Parameter Name="SII_NAME" Type="String" />
                        <asp:Parameter Name="SII_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="SII_OWNER_NAME" Type="String" />
                        <asp:Parameter Name="SII_OWNER_EMAIL" Type="String" />
                        <asp:Parameter Name="SII_URL" Type="String" />
                        <asp:Parameter Name="original_SII_ID" Type="Int64" />
                        <asp:Parameter Name="original_INSTALL_ID" Type="Int64" />
                        <asp:Parameter Name="original_SII_IS_ACTIVE" Type="Boolean" />
                        <asp:Parameter Name="original_SII_NAME" Type="String" />
                        <asp:Parameter Name="original_SII_DESCRIPTION" Type="String" />
                        <asp:Parameter Name="original_SII_OWNER_NAME" Type="String" />
                        <asp:Parameter Name="original_SII_OWNER_EMAIL" Type="String" />
                        <asp:Parameter Name="original_SII_URL" Type="String" />
                    </UpdateParameters>
                </asp:SqlDataSource>
            </td>
        </tr>
    </table>
</asp:Content>
